package com.mjlf.project.service;

import com.mjlf.framework.annotation.Autowired;
import com.mjlf.framework.annotation.Component;
import com.mjlf.project.dao.UserDao;
import com.mjlf.project.entity.User;

import java.util.List;

/**
 * 登录服务类
 */
@Component
public class LoginService {

    @Autowired
    private UserDao userDao;

    public boolean login(User user){
        List<User> users = userDao.getUserByName(user.getUsername());
        for(User u : users){
            if(user.getUsername().equals(u.getUsername()) && user.getPassword().equals(u.getPassword())){
                return true;
            }
        }
        return false;
    }

    public UserDao getUserDao(){
        return this.userDao;
    }
}
